<!DOCTYPE HTML>
<html>
<head>
    <script type="text/javascript" src="../js/common.js"></script>
    <title>添加角色</title>
</head>
<body>
<div class="pd-20">
    <div class="Huiform">
        <form class="form" onsubmit="return false">
            <table class="table table-bg">
                <tbody>
                <input type="hidden" style="width:200px" class="input-text" id="id" name="id" readonly>
                <tr>
                    <th width="100" class="text-r"><span class="c-red">*</span> 角色名：</th>
                    <td><input type="text" style="width:200px" class="input-text" value="" placeholder=""
                               id="role" name="role" datatype="*2-16" nullmsg="权限名称不能为空"></td>
                </tr>

                <tr>
                    <th width="100" class="text-r"><span class="c-red"></span> 描述：</th>
                    <td><input type="text" style="width:200px" class="input-text" value="" placeholder=""
                               id="description" name="description"></td>
                </tr>
                <tr>
                    <th></th>
                    <td>
                        <button type="submit" class="btn btn-primary"><i
                                class="glyphicon glyphicon-ok"></i>确定
                        </button>
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
</div>
<script type="text/javascript">
    $(".form").Validform({
        callback: function () {
            var data = $(".form").serialize();
            requestService("/role/save", "post", true, data,
                    function (result) {
                        layer.msg(result.desc);
                        setTimeout(function () {
                            parent.window.location.reload();
                            layer_close();
                        }, 500);
                    }, null);
        }
    });
    var id = getQueryVariable("id");
    if (id != "") {//编辑
        var row = JSON.parse(window.sessionStorage.getItem("row"));
        $("#id").val(id);
        $("#role").val(row.role);
        $("#description").val(row.description);
    }
</script>
</body>
</html>